/* 单行省略 */
@mixin l-e-o {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/**
   * 多行省略
   * @include l-e-m(3)
*/
@mixin l-e-m($value: 3) {
  display: -webkit-box;
  box-orient: vertical;
  -webkit-box-orient: vertical;
  line-clamp: $value;
  -webkit-line-clamp: $value;
  overflow: hidden;
}

/**
  * 最大宽度+左右居中
  * @include max-w(1200)
*/
@mixin max-wh($value: 1200) {
  width: $value +px;
  margin: 0 auto;
}

/* 弹性盒子 */
$type: 1 !default;

@mixin flex-box {
  display: flex;

  @if $type==1 {
    justify-content: space-between;
  }

  @else if $type==2 {
    justify-content: center;
  }

  @else {
    justify-content: space-around;
  }
}


@mixin static {
  @if $type==1 {
    position: absolute;
  }

  @else if $type==2 {
    position: relative;
  }

  @else {
    position: fixed;
  }

  left: 0;
  top: 0;
  bottom: 0;
  right: 0;
}

/* 默认边距 */
$side: 1 !default;

@mixin side($valOne: 10, $valTwo: 3) {
  @if $side==1 {
    margin: $valOne + px $valTwo + px;
  }

  @else if $side==2 {
    margin: torem($valOne) torem($valTwo);
  }

  @else {
    padding: 17px 16px;
  }
}


/**
  *父盒子相对定位，当前盒子如下
  *使用示例
  &:before{
    @include border(0,17,bottom);
    top: unset; //不设顶部高度
  } 
**/
@mixin border($lt:16, $rg:0, $horz: top) {
  content: " ";
  position: absolute;
  left: $lt + px;
  right: $rg + px;
  top: 0;
  height: 1px;
  border-#{$horz}: 1px solid rgba(0, 0, 0, 0.1);
  color: rgba(0, 0, 0, 0.1);
  transform-origin: 0 0;
  -webkit-transform-origin: 0 0;
  transform: scaleY(0.5);
  -webkit-transform: scaleY(0.5);
  z-index: 2;
}

/* 垂直水平居中 */
@mixin vt-c {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  top: 0;
  display: flex;

  &:after {
    margin: auto;
  }
}

/* px转换rem */
$browser-default-font-size: 37.5px !default;

@function torem($px) {
  @if (unitless($px)) {
    @return torem($px + 0px);
  }

  @else if (unit($px)==em) {
    @return $px;
  }

  @return ($px / $browser-default-font-size) * 1rem;
}

/* 计算两个值的百分比，默认设计稿宽/设计稿高 */
@function percent ($width: 375, $height: 667) {
  @return $width / $height * 100%
}

/* 计算em */
@function toEm ($child: 16, $parent: 16) {
  @return $child / $parent+em
}